home *** CD-ROM | disk | FTP | other *** search
- Path: keats.ugrad.cs.ubc.ca!not-for-mail
- From: c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku)
- Newsgroups: comp.lang.c
- Subject: Re: Best Binary Search Tree Balance Algo?
- Date: 10 Mar 1996 13:23:29 -0800
- Organization: Computer Science, University of B.C., Vancouver, B.C., Canada
- Message-ID: <4hvh8hINN5vq@keats.ugrad.cs.ubc.ca>
- References: <4hqvc5$p9k@solaria.cc.gatech.edu> <richmond-0903962355070001@aux82.plano.net>
- NNTP-Posting-Host: keats.ugrad.cs.ubc.ca
-
- In article <richmond-0903962355070001@aux82.plano.net>,
- Charles Richmond <richmond@plano.net> wrote:
- >In article <4hqvc5$p9k@solaria.cc.gatech.edu>, bigdave@cc.gatech.edu
- >(David Mitchell) wrote:
- >> I would like to know what the run-time of the best binary search tree
- >> balance algorithm is. (e.g. O(n^2), O(n lg n), etc.).
- >>
- >I believe the AVL balanced tree algorithm is the fastest. It works in
- >big-O of log base 2 of n. The red/black balanced tree algorithm is
-
- It works in O(log n) for doing a rebalancing operation when you insert one node
- into an already balanced tree.
-
- >*almost* as good. It works in the same big-O time, but has larger constant
- >terms in the performance equation.
-
- I think you got that backwards. AVL is the intuitive, but slow, way to do tree
- balancing. Red-Black is the clever algorithm which gives you the same
- asymptotic complexity as AVL, but improves the constants.
-
- Red-Black does not achieve perfect order, but it does ensure that the deepest
- node is not more than twice as deep as the shallowest node. By enforcing this
- constraint, it ensures that lookups are still O(log n) (this is easy to prove),
- but the re-balancing is sped up.
- --
-
-